home *** CD-ROM | disk | FTP | other *** search
- /****** axuucp/ax-uuxqt ******************************************************
- *
- * NAME
- * ax-uuxqt - Import UUCP mail and news executing UUCP command files
- *
- * SYNOPSIS
- * rx ax-uuxqt.rexx [feed]
- *
- * DESCRIPTION
- *
- * BUGS
- * Due to some bugs (features ?) in /bin/mailserver 1.15 (which does not
- * fully support RFC 822 Mail headers, mails to and from unroutable
- * systems will get lost!
- *
- * AUTHOR
- * Tobias Ferber <tf@ganymed.hall.sub.org>
- *
- ******************************************************************************
- *
- */
-
- feed = left(arg(1),min(length(arg(1)),7))
-
- if words(feed) < 1 then do
- say 'usage: ax-uucico [feed]'
- exit 10
- end
-
- spooldir = strfmt(axconfig("axuucp.spooldir"),"%u",feed)
-
- if ~exists(spooldir) then do
- say 'ax-uuxqt: No such spool directory "'spooldir'"'
- exit 10
- end
-
- axmail = axconfig("mail")
- aka = axconfig("thismachine")
- tempfile = "T:ax-uuxqt." || pragma('Id')
- pat = "X." || feed || "?" || "????"
-
- files=0; news=0; mails=0; errors=0;
-
- address command 'List FILES DIR "'spooldir'" PAT "'pat'" LFORMAT "%p%n" > "'tempfile'"'
-
- call open('fp',tempfile)
- do until eof('fp')
- xfile= readln('fp')
- if words(xfile) > 0 then do
- err= uuxqt(xfile)
- if err>0 then errors= errors+1
- files= files+1;
- end
- end
-
- call close('fp')
- address command 'Delete QUIET "'tempfile'"'
- say 'ax-uuxqt:' files 'files,' news 'news,' mails 'mails,' errors 'errors'
- exit
-
-
- uuxqt: procedure expose spooldir aka axmail news mails;
- parse arg xfile
- dfile=''; cmd=''; err= 0
- call open('xfp',xfile)
- do until eof('xfp')
- str= readln('xfp')
- if words(str) > 0 then do
- parse var str lhs ' ' rhs
- select
- when (upper(lhs)='F') | (upper(lhs)='I') then dfile= rhs
- when (upper(lhs)='C') then cmd=rhs
- otherwise nop
- end
- end
- end
- call close('xfp')
-
- if (words(dfile) > 0) & (words(cmd) > 0) then do
- dfile= spooldir || dfile
- if exists(dfile) then do
- select
- when upper(left(cmd,5)) = "RNEWS" then do
- /*say xfile': posting news from "'dfile'"'*/
- address command 'rx axsh:rexx/ax-rnews.rexx < "'dfile'"'
- news= news+1
- end
- when upper(left(cmd,5)) = "RMAIL" then do
- address command 'rx axsh:rexx/ax-rmail.rexx < "'dfile'"'
- /*
- toaddr= substr(cmd,7); user=''; domain=''
- select
- when pos('@',toaddr) > 0 then parse var toaddr user '@' domain
- when pos('!',toaddr) > 0 then parse var toaddr domain '!' user
- otherwise user= toaddr
- end
- if (words(domain) = 0) | (domain = aka) then do
- say xfile': sending mail to "'user'"'
- mbox= axmail || user
- /*address command 'AXsh:bin/mailserver "'dfile'"'*/
- address command 'Type "'dfile'" >> "'axmail || user'"'
- address command 'Echo "" >> "'mbox'"' /* force 'body null' */
- */
- mails= mails+1
- /*
- end
- else do
- say xfile': cannot deliver mail to "'toaddr'" (no route to "'domain'")'
- err= 1
- end
- */
- end
- otherwise do
- say xfile': operation not permitted "'cmd'"'
- err= 2
- end
- end /* select */
- if ((err=0) & exists(dfile)) then address command 'Delete QUIET "'dfile'"'
- end
- else do
- say xfile': file "'dfile'" not found'
- err= 3
- end
- if err=0 then address command 'Delete QUIET "'xfile'"'
- end
- else do
- say xfile': missing command (C) or filename (F,I)'
- err= 4
- end
-
- return err
-
-
- /*@<axconfig><strfmt>*/
-
- /* get an AXsh configuration value */
-
- axconfig: procedure
- tempfile = "T:axconfig." || pragma('Id')
- rc_index = "AXsh:rexx/rc.index"
- var_val=""; var_file=""; var_defval="";
-
- parse upper arg var_name
- if left(var_name,1) ~= '%' then var_name = '%'var_name
- if right(var_name,1) ~= ':' then var_name = var_name':'
-
- if open('idx',rc_index,'Read') then do
- do until (eof('idx') | (var_file~=''))
- str= translate(readln('idx'),' ',d2c(9))
- if words(str) > 0 then do
- parse var str vname ' ' fname '"' defval '"'
- if upper(vname) = var_name then do
- var_file= strip(fname,'B',' 'd2c(9))
- var_defval= defval
- end
- end
- end
- call close('idx')
- end
- else say 'Could not read "'rc_index'"'
-
- if words(var_file) > 0 then do
- if open('rc',var_file,'Read') then do
- do until (eof('rc') | (var_val~=''))
- str= translate(readln('rc'),' ',d2c(9))
- if upper(word(str,1)) = var_name then var_val = strip(readln('rc'),'B',' 'd2c(9))
- end
- call close('rc')
- end
- else say 'Could not examine "'var_file'" for' var_name
- end
- else do
- if words(var_defval) > 0 then var_val= var_defval
- else say 'No such config variable:' var_name
- end
-
- return var_val
-
-
- /* substitute all occurences of 'fmt' in 'str' by 'val' */
-
- strfmt: procedure
- parse arg str,fmt,val
- p= pos(fmt,str)
- do while p>0
- str= left(str,p-1) || val || substr(str,p+length(fmt))
- p= pos(fmt,str)
- end
- return str
-
-
-